import { defineStore } from "pinia";
import { ref } from "vue";

const useSystemStore = defineStore(
  "systemStore",
  () => {
    // 设置默认值才能被 $reset 重置
    const isCollapse = ref<boolean>(false);

    const setCollapse: (flag: boolean) => void = (flag = false) => {
      isCollapse.value = flag;
    };

    return {
      isCollapse,
      setCollapse,
    };
  },
  {
    persist: {
      enabled: true,

      strategies: [
        {
          storage: sessionStorage,
          paths: ["system"],
        },
      ],
    },
  } as any
);

export default useSystemStore;
